package com.ucw.ucwclient.biz.service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ucw.ucwclient.dal.dataobject.UOrg;
import com.ucw.ucwclient.dal.mapper.UOrgMapper;
import com.ucw.ucwclient.dal.search.NormalSearch;

@Service
public class OrgService {

	@Resource
	private UOrgMapper orgMapper;

	public List<UOrg> getList(NormalSearch search) {

		return orgMapper.selectByPageSearch(search);
	}

	public UOrg getOne(Long id, Long userId) {
		return orgMapper.selectByPrimaryKey(id);
	}

	public Map<String, String> addOne(UOrg org, Long userId) {
		org.setUserId(userId);
		org.setCreateTime(new Date());
		int result = orgMapper.insertSelective(org);
		Map<String, String> resp = new HashMap<String, String>();
		if (result == 1) {
			resp.put("resultMsg", "success");
			resp.put("code", "200");

		} else {
			resp.put("resultMsg", "fail");
		}
		return resp;
	}

}
